<!DOCTYPE html>
<!--suppress ALL-->
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="author" content="order by dede58.com"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="img/logo.png"/>
    <title>申请开课</title>
    <link href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/bootstrap.min.css" />
    <script src="../layui/layui.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script type="text/javascript" src="../js/ajaxfileupload.js"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <script type="text/javascript" th:inline="javascript">
    <![endif]-->



    <style>
        html,body {
            height: 100%;
        }
        .box {
            /*filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#6699FF', endColorstr='#6699FF'); /!*  IE *!/*/
            /*background-image:linear-gradient(bottom, #6699FF 0%, #6699FF 100%);*/
            /*background-image:-o-linear-gradient(bottom, #6699FF 0%, #6699FF 100%);*/
            /*background-image:-moz-linear-gradient(bottom, #6699FF 0%, #6699FF 100%);*/
            /*background-image:-webkit-linear-gradient(bottom, #6699FF 0%, #6699FF 100%);*/
            /*background-image:-ms-linear-gradient(bottom, #6699FF 0%, #6699FF 100%);*/
            background-image:url("img/bg-login.png");
            background-repeat: no-repeat;
            background-size: 100%;
            margin: 0 auto;
            position: relative;
            width: 100%;
            height: 100%;
        }
        .login-box {
            width: 100%;
            max-width:500px;
            height: 400px;
            position: absolute;
            top: 50%;


            margin-top: -300px;
            /*设置负值，为要定位子盒子的一半高度*/

        }
        @media screen and (min-width:500px){
            .login-box {
                left: 50%;
                /*设置负值，为要定位子盒子的一半宽度*/
                margin-left: -250px;
            }
        }

        .form {
            width: 100%;
            max-width:500px;
            height: 275px;
            margin: 25px auto 0px auto;
            padding-top: 25px;
        }
        .login-content {
            height: 600px;
            width: 100%;
            max-width:500px;
            background-color: rgba(255, 250, 2550, .6);
            float: left;
        }


        .input-group {
            margin: 0px 0px 30px 0px !important;
        }
        .form-control,
        .input-group {
            height: 40px;
        }

        .form-group {
            margin-bottom: 0px !important;
        }
        .login-title {
            padding: 20px 10px;
            background-color: rgba(0, 0, 0, .6);
        }
        .login-title h1 {
            margin-top: 10px !important;
        }
        .login-title small {
            color: #fff;
        }

        .link p {
            line-height: 20px;
            margin-top: 30px;
        }
        .btn-sm {
            padding: 8px 24px !important;
            font-size: 16px !important;
        }
        .text-white{
            color: white;
        }
    </style>
</head>
<body>
<div class="box">
    <br/>
    <h1 class="text-center text-white"><span class="glyphicon glyphicon-leaf"></span>&nbsp;&nbsp;申请开课</h1>
    <div class="login-box">
        <div class="login-title text-center">
            <h1><small>申请开课</small></h1>
        </div>
        <div class="login-content ">
            <div class="form">
                <form action="user/register" method="post">

                    <div class="form-group">
                        <div class="col-xs-12  ">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                                <input type="text" id="userId" name="userId" class="form-control" placeholder="请输入课程名称">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-xs-12  ">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                                <input type="text" id="gname" name="gname" class="form-control" placeholder="教师姓名">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-xs-12  ">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                                <input type="text" id="goprice" name="goprice" class="form-control" placeholder="请输入课程内容">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="button"  class="btn btn-success" id="register" >确定</button>
                            <button type="reset" class="btn btn-primary" >重置</button>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-xs-12 link">
                            <p class="text-center remove-margin"><small>放弃申请,请点击</small> <a href="course-applyIndex.html" ><small>返回</small></a>
                            </p>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>


<script src="js/jquery-1.11.3.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript" src="../js/ajaxfileupload.js"></script>
</body>
<script>
    $("#userId").blur(function(){
        var  userId=	$("#userId").val();
        var url="/checkUserId";
        var param={"userId":userId};
        $.post(url,param,function(data){
            if(data.code==200){
                layer.msg(data.message);
            }else{
                layer.msg(data.message);
            }
        },"json");
    });

    $("#gname").blur(function(){
        var  gname=	$("#gname").val();
        var url="/checkGname";
        var param={"gname":gname};
        $.post(url,param,function(data){
            if(data.code==200){
                layer.msg(data.message);
            }else{
                layer.msg(data.message);
            }
        },"json");
    });

    //判断确认密码和密码的一致性
    $("#grprice").blur(function(){
        //获取密码和确认密码
        var goprice =	$("#goprice").val();
        var grprice = $("#grprice").val();
        //发起ajax请求  安全性密码请求post
        var url="/checkBusinessPrice";
        var param={"goprice":goprice,"grprice":grprice};
        $.post(url,param,function(data){
            if(data.code==200){
                layer.msg(data.message);
            } else{
                layer.msg(data.message);
            }
        },"json");
    });


    $("#goodsTypeId").blur(function(){
        var  goodsTypeId=	$("#goodsTypeId").val();
        var url="/checkGoodsTypeId";
        var param={"goodsTypeId":goodsTypeId};
        $.post(url,param,function(data){
            if(data.code==200){
                layer.msg(data.message);
            }else{
                layer.msg(data.message);
            }
        },"json");
    });



    $("#img-change").click(function () {
        $("#file").click();
    })


    // $("#file").change(function (event) {
    var filechange = function (event) {
        var files = event.target.files, file;
        if (files && files.length > 0) {
            // 获取目前上传的文件
            file = files[0];// 文件大小校验的动作
            if (file.size > 1024 * 1024 * 2) {
                alert('图片大小不能超过 2MB!');
                return false;
            }
            // 获取 window 的 URL 工具
            var URL = window.URL || window.webkitURL;
            // 通过 file 生成目标 url
            var imgURL = URL.createObjectURL(file);
            //用attr将img的src属性改成获得的url
            $("#img-change").attr("src", imgURL);
            // 使用下面这句可以在内存中释放对此 url 的伺服，跑了之后那个 URL 就无效了
            // URL.revokeObjectURL(imgURL);
        }
    };
    // });

     $("#register").click(function () {
       $.ajaxFileUpload({
         url: '/saveGpicture',
        fileElementId:'file',
        dataType:'txt',
        secureuri : false,
        success: function (data){
            if(data!=null){
                layer.msg("OK");
                var userId =	$("#userId").val();
                var gname =	$("#gname").val();
                var goprice =	$("#goprice").val();
                var grprice =	$("#grprice").val();
                var gpicture =	data
                var goodsTypeId =$("#goodsTypeId").val();
                var url1="/doGoodsAdd";
                var param={"userId":userId,"gname":gname,
                    "goprice":goprice,"grprice":grprice,
                    "gpicture":gpicture,"goodsTypeId":goodsTypeId}
                $.post(url1 , param , function (data1) {
                    if (data1.code == 200){
                        layer.msg(data1.message);
                        location.href="/bindex";
                    } else {
                        layer.msg(data1.message);
                    }
                });
            } else{
                alert(data.code);
                return;
                // layer.msg(data.message);
            }
        },
        error:function(data,status,e){
            layer.msg(data);
        }
    });
    });



</script>
</html>